package cn.nbt.busManage.dao.repository;

import cn.nbt.busManage.model.entity.Point;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * {@code @Author} lyq
 * {@code @Date} 6/11/2024 5:09 PM
 */
@Repository
public interface PointRepository extends JpaRepository<Point,Integer> {

    /**
     * 更新站点信息
     * @param pointName 站点名称
     */
    @Modifying
    @Query("update Point p  set p.pointName=:pointName, p.latitudeLongitude=:latitudeLongitude where p.id=:id")
    void updatePoint(@Param("pointName") String pointName, @Param("latitudeLongitude") String latitudeLongitude, @Param("id") int id);

    /**
     * 根据站点名称查询站点
     * @param pointName 站点名称
     * @return 站点信息
     */
    @Query("select p from Point p where p.pointName = :pointName")
    Point findByPointName(@Param("pointName") String pointName);
}
